<?php
require_once dirname(dirname(__FILE__)) . '/shared/config/config.php';
require_once DOCUMENT_ROOT . DIR_ADMIN_INCLUDE . 'check_user_login.php';
?>
<!DOCTYPE html>
<html>
    <head id="Head1">
        <title>
            Default Working Paper Description - Tesdo Admin
        </title>
        <?php
        require_once DOCUMENT_ROOT . DIR_ADMIN_INCLUDE . 'head.php';
        ?>
    </head>
    <body>
        <?php
        require_once DOCUMENT_ROOT . DIR_ADMIN_INCLUDE . 'header.php';
        require_once DOCUMENT_ROOT . DIR_SHARED_LIBRARIES . 'lib_pager.php';
        require_once DOCUMENT_ROOT . DIR_SHARED_LIBRARIES . 'lib_data_input.php';
        require_once DOCUMENT_ROOT . DIR_SHARED_DAO . 'dao_working_papers.php';
        require_once DOCUMENT_ROOT . DIR_ADMIN_INCLUDE . 'ckeditor.php';

        //Script Process Page
        //Get objects
        $dao_working_paper = new dao_working_paper();
        $lib_pager = new lib_pager();
        $lib_data_input = new lib_data_input();

        //-------------Form_Load-------------
        //POST process
        if ($_SERVER['REQUEST_METHOD'] == "POST") {
            if (!empty($_POST['btnSave'])) {
                if (!empty($_POST['a_default_paper_description'])) {
                    $dao_working_paper->set_default_description($_POST['a_default_paper_description']);
                    $success = "Default paper description is edited!";
                } else {
                    $error = "This description must not be empty!";
                }
            } else if (!empty($_POST['btnCancel'])) {
                ?>
                <script type="text/javascript">
                    window.location = <?php echo LINK_ROOT . DIR_ADMIN . 'default_paper_descripton.php'; ?>;
                </script>
                <?php
            }
        }
        
        $edit_item = $dao_working_paper->get_default_description();
        ?>

        <div>
            <div class="content-box-outer">
                <div class="content-box-right">
                </div>
                <div class="content-box-left">
                    <h1>Default Paper Description</h1>
                    <div class="MessageArea">
                        <?php if (!empty($error)) { ?>
                            <span id="cphAdmin_lblMsg" style="color: red;">
                                <?php echo $error; ?>
                            </span>
                        <?php } ?>
                        <?php if (!empty($success)) { ?>
                            <span id="cphAdmin_lblMsg" style="color: green;">
                                <?php echo $success; ?>
                            </span>
                        <?php } ?>
                    </div>
                    <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" id="form_conference" method="POST" enctype="multipart/form-data">
                        <div>
                            <div class="TitleArea"><b>Default Paper Description:<span style="color: red;">*</span></b></div>
                            <div class="textBoxArea">
                                <textarea name="a_default_paper_description" id="a_default_paper_description" class="ckeditor">
                                    <?php if (!empty($edit_item)) { ?>
                                        <?php echo $edit_item['paper_default_description']; ?>
                                    <?php } ?>
                                </textarea>
                            </div>

                            <div class="TitleArea"><b>.</b></div>
                            <div class="textBoxArea">
                                <input type="submit" name="btnSave" value="Save" class="buttonDesign">
                                <input type="submit" name="btnCancel" value="Cancel" class="buttonDesign">
                            </div>
                        </div>
                        <br clear="all"><br>
                    </form>
                </div>
            </div>
        </div>

        <?php
        require_once DOCUMENT_ROOT . DIR_ADMIN_INCLUDE . 'footer.php';
        ?>
    </body>
</html>
